<?php
namespace Home\Controller;
use Think\Controller;
class CatalogController extends Controller {
	public function index($id){
		$Fl = D("Fl");
		$fllist = $Fl->order('flpx asc')->select();
		$Article = D("Article");
		$map['flid'] = $id ;
		$where['id'] = $id ;
		$flname = $Fl->where($where)->getField('flname');
		$list = $Article->where($map)->select();
		$zxlist = $Article->limit(10)->order('id desc')->select();
		$sjlist = $Article->limit(10)->order('rand()')->select();
		$this->assign('fllist',$fllist);
		$this->assign('flname',$flname);
		$this->assign('list',$list);
		$this->assign('zxlist',$zxlist);
		$this->assign('sjlist',$sjlist);
		$this->display();
	}
	public function view($id){
		$Fl = D("Fl");
		$fllist = $Fl->order('flpx asc')->select();
		$Article = D("Article");
		$map['id'] = $id ;
		$result = $Article->where($map)->relation(true)->find();
		$zxlist = $Article->limit(10)->order('id desc')->select();
		$sjlist = $Article->limit(10)->order('rand()')->select();
		$front = $Article->where("id<".$id)->order('id desc')->limit('1')->find();//获取上一篇
		$after = $Article->where("id>".$id)->order('id desc')->limit('1')->find();//获取下一篇
		$this->assign('fllist',$fllist);
		$this->assign('zxlist',$zxlist);
		$this->assign('sjlist',$sjlist);
		$this->assign('result',$result);
		$this->assign('front',$front);//上一篇
		$this->assign('after',$after);//下一篇
		$this->display();
	}
}